package org.example.filters;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Description: 过滤器需要在servlet容器中实现，需要手动注入到 spring 容器中，否则不会生效
 */

@WebFilter(filterName = "testFilter", urlPatterns = "/*")// 当前配置拦截所有请求
@Component
public class TestFilter implements Filter {
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("过滤器TestFilter测试执行..........");
        chain.doFilter(request, response);
    }
}
